from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False,args=['--start-maximized'])
    context = browser.new_context()
    page = context.new_page()

    # 打开仓储系统
    page.goto("http://172.28.1.3:2460/")
    # 输入账号和密码
    page.get_by_placeholder("您的账号").type("kuanglei", delay=30)
    page.get_by_placeholder("请输入您的密码").fill("123456")
    # 点击登录
    page.get_by_role("button").click()

    page.get_by_text("入库管理").click()
    page.get_by_role("link", name="质检单").click()
    page.get_by_role("link", name="质检单").first.click()
    page.get_by_role("row", name="CD202407050001 ABS/北京首塑/A310").locator("a").nth(1).click()
    page.locator("input[type=\"text\"]").first.click()
    page.locator("input[type=\"text\"]").first.fill("001")
    page.locator("input[type=\"text\"]").nth(1).click()
    page.locator("input[type=\"text\"]").nth(1).fill("5")
    page.locator("input[type=\"text\"]").nth(2).click()
    page.locator("input[type=\"text\"]").nth(2).fill("5")
    page.locator("input[type=\"text\"]").nth(3).click()
    page.locator("input[type=\"text\"]").nth(3).fill("0")
    page.locator(".arco-select-view-input").first.click()
    page.get_by_text("抽检").click()
    page.locator(
        "div:nth-child(6) > .arco-row > div:nth-child(2) > .arco-form-item-content-wrapper > .arco-form-item-content > .arco-select-view-single > .arco-select-view-input").click()
    page.get_by_text("合格，符合做代理业务").click()
    page.get_by_placeholder("请选择质检时间").click()
    page.get_by_text("今天").click()
    page.get_by_role("button", name="保存并确认质检").click()

    # ---------------------
    context.close()
    browser.close()